﻿using System;
using C = KC.Constants;
namespace KC.Logging
{
	/// <summary>Log files are managed here.</summary>
	public static class LogFileManagement
	{
		/// <summary>Is the current log file full (i.e. up to its max size)?</summary>
		/// <returns>True = full; false = not full</returns>
		internal static bool isLogFull()
		{
			return new System.IO.FileInfo(C.Logging.LogFile).Length >= KC.Constants.Logging.MaxLogSize;
		}
		/// <summary>For use when log file is full. Rolls the logfile to an archive and starts up a new one.</summary>
		internal static void RollLogs()
		{
			// i.e. move c:\logs\wtf.log to c:\logs\wtf_12012010_173000.log
			System.IO.File.Move(C.Logging.LogFile, System.IO.Path.GetFileNameWithoutExtension(C.Logging.LogFile) + "_" + DateTime.Now.ToString("MMddyyyy_HHmmss") + System.IO.Path.GetExtension(C.Logging.LogFile));
			System.IO.File.WriteAllText(C.Logging.LogFile, "");
		}
	}
}
